package com.jjh.util;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;

/**
 * 根据类型创建对象
 * @author JJH
 */
public class TypeUtils {

   public static Object getInstanceByType(String str,Class<?> clazz){

        if(clazz==int.class){
            return Integer.parseInt(str);
        } else if (clazz==long.class) {
            return Long.parseLong(str);
        }else if (clazz==char.class){
            return null;
        }else if(clazz==short.class){
            return Short.parseShort(str);
        }else if(clazz==String.class){
            return str;
        } else if (clazz==double.class) {
            return Double.parseDouble(str);
        }else if(clazz==float.class){
            return Float.parseFloat(str);
        }else if(clazz== LocalDateTime.class){
            return  LocalDateTime.parse(str);
        }


       return null;
    }

}
